﻿@model Api.Model.MethodParameter
@{
    Layout = "~/Areas/Admin/Views/Shared/_AdminLayout.cshtml";
    var methodId = Request.QueryString["methodId"];
}
@section seo{
    <title>@ViewBag.Title</title>
}
@section script{
    <script type="text/javascript">
        $(function () {
            editors.push('Description');
            window.postUrl = '@Url.Action("Edit", new {Area = "Admin", Th.ProjectId })';
            window.form = $('#form1');
            bindValidate(ajaxSubmit, form);
            initData();
        });

        //选中参数类型
        function initData() {
            var type = '@(Model?.Type)';
            var isRequired = '@(Model?.IsRequired)'.toLocaleLowerCase();
            $('[name="Type"]').filter(function () {
                return $(this).val() == type;
            }).prop('checked', true)
            $('[name="IsRequired"]').filter(function () {
                return $(this).val() == isRequired;
            }).prop('checked', true)
        }

        function ajaxSubmit() {
            msgBox.showMsgWait("正在提交");
            var data = $(form).serialize();
            $.post(postUrl, data, function (ajaxMsg) {
                msgBox.showMsg(ajaxMsg);
                if (ajaxMsg.status == 1) {
                    location.reload();
                }
            })
        }
    </script>
    <script>
        $(function () {
            window.form = $('#form1');
            window.deleteUrl = '@Url.Action("Delete")';
        });


        //删除记录
        function deleteIds() {
            var chkIds = $("input:checked[type=checkbox]", $('#tbody'));
            if (chkIds.length == 0) {
                msgBox.showMsgErr("請選擇一項");
                return false;
            }
            var obj = window.confirm("確定刪除嗎");
            var data = $(form).serialize();
            if (obj) {
                $.post(deleteUrl, data, function (ajaxMsg) {
                    msgBox.showMsg(ajaxMsg);
                    $.each(chkIds, function () {
                        $(this).parents('tr').remove();
                    })
                });
            }
        }

        //修改tbody中tr的样式
        function changeTrClass() {
            $('#tbody tr').each(function (i, element) {
                if (i % 2 == 0) {
                    $(element).addClass('zxbejing');
                }
            });
        };
    </script>
}
<form id="form1">
    @Html.AntiForgeryToken()
    <!--左邊菜單--開始-->
    @Html.Partial("_LeftMenu")
    <!--左邊菜單--結束-->
    <!--右邊--B-->
    <div class="shanpin_right">
        <div class="productfun">
            <div class="proct1 col-lg-2 col-sm-3 col-xs-3"><span class="product_name_hk">&nbsp;</span></div>
            <div class="proct2 col-lg-9 col-sm-4 col-xs-9">
                <input type="submit" id="btnSave" value="保存" class="save_continue button button-glow button-rounded button-royal" />
                <a class="save_continue button button-glow button-rounded button-royal" href="@Url.Action("List", "Method",new { Th.ProjectId})">返回</a>
                <a class="save_continue button button-glow button-rounded button-royal" href="@Url.Action("Create","MethodParameter",new { Th.ProjectId,methodId})">新增</a>
                <a class="save_continue button button-glow button-rounded button-royal" href="@Url.Action("Edit","Method",new { Th.ProjectId,Id=methodId})">修改接口及定義</a>
            </div>
            <div class="proct3 col-lg-9 col-sm-5 col-xs-4"><span class="hk_cn"></span></div>
            <div class="clear"></div>
        </div>
        <div style="height: 20px;"></div>
        @Html.Partial("_Message", new TipMessage() { TipStatus = TipStatus.Error, Message = ViewBag.Error })
        @Html.Partial("_Message", new TipMessage { TipStatus = TipStatus.Info, Message = ViewBag.Info })
        @Html.Partial("_Message", new TipMessage { TipStatus = TipStatus.Warning, Message = ViewBag.Warning })
        @Html.Partial("_Message", new TipMessage { TipStatus = TipStatus.Success, Message = ViewBag.Success })
        <input type="hidden" value='@Request.QueryString["projectId"]' name="projectId" />
        <input type="hidden" value="@(Model?.Id)" name="Id" />
        <input type="hidden" value="@methodId" name="methodId" />
        <div class="productfun">
            <div class="proct1 col-lg-2 col-sm-3 col-xs-3"><span class="product_name_hk"><font class="star">*</font>參數名稱</span></div>
            <div class="proct2 col-lg-9 col-sm-4 col-xs-9">
                @Html.TextBoxFor(s => s.Name, new { @class = "form-contds required", @maxlength = "100" })
                <span id="Name-error"></span>
            </div>
            <div class="proct3 col-lg-9 col-sm-5 col-xs-4"><span class="hk_cn"></span></div>
            <div class="clear"></div>
        </div>
        <div class="productfun">
            <div class="proct1 col-lg-2 col-sm-3 col-xs-3"><span class="product_name_hk"><font class="star">*</font>參數類別</span></div>
            <div class="proct2 col-lg-9 col-sm-4 col-xs-9">
                <label>
                    <input type="radio" name="Type" class="form-contds" value="@ParameterType.Query" checked="checked" />@ParameterType.Query
                </label>
                <label>
                    <input type="radio" name="Type" class="form-contds" value="@ParameterType.Return" />@ParameterType.Return
                </label>
                <span id="Type-error"></span>
            </div>
            <div class="proct3 col-lg-9 col-sm-5 col-xs-4"><span class="hk_cn"></span></div>
            <div class="clear"></div>
        </div>
        <div class="productfun">
            <div class="proct1 col-lg-2 col-sm-3 col-xs-3"><span class="product_name_hk"><font class="star">*</font>數據類型</span></div>
            <div class="proct2 col-lg-9 col-sm-4 col-xs-9">
                <input id="DataType" type="text" name="DataType" class="form-contds required" value="@(Model?.DataType)" />
                <span id="DataType-error"></span>
            </div>
            <div class="proct3 col-lg-9 col-sm-5 col-xs-4"><span class="hk_cn"></span></div>
            <div class="clear"></div>
        </div>
        <div class="productfun">
            <div class="proct1 col-lg-2 col-sm-3 col-xs-3"><span class="product_name_hk"><font class="star">*</font>默認值</span></div>
            <div class="proct2 col-lg-9 col-sm-4 col-xs-9">
                <input id="DefaultValue" type="text" name="DefaultValue" class="form-contds" value="@(Model?.DefaultValue)" />
                <span id="DefaultValue-error"></span>
            </div>
            <div class="proct3 col-lg-9 col-sm-5 col-xs-4"><span class="hk_cn"></span></div>
            <div class="clear"></div>
        </div>
        <div class="productfun">
            <div class="proct1 col-lg-2 col-sm-3 col-xs-3"><span class="product_name_hk"><font class="star">*</font>是否必填</span></div>
            <div class="proct2 col-lg-9 col-sm-4 col-xs-9">
                <label>
                    <input type="radio" name="IsRequired" class="form-contds" value="true" checked="checked" />是
                </label>
                <label>
                    <input type="radio" name="IsRequired" class="form-contds" value="false" />否
                </label>
                <span id="IsRequired-error"></span>
            </div>
            <div class="proct3 col-lg-9 col-sm-5 col-xs-4"><span class="hk_cn"></span></div>
            <div class="clear"></div>
        </div>
        <div class="productfun">
            <div class="proct1 col-lg-2 col-sm-3 col-xs-3"><span class="product_name_hk"><font class="star">*</font>描述</span></div>
            <div class="proct2 col-lg-9 col-sm-4 col-xs-9">
                @Html.TextAreaFor(s => s.Description, new { @class = "form-contds", @style = "width:800px;height:600px" })
                <span id="Description-error"></span>
            </div>
            <div class="proct3 col-lg-9 col-sm-5 col-xs-4"><span class="hk_cn"></span></div>
            <div class="clear"></div>
        </div>
        <!--按鈕-->
        <div class="productfun">
            <div class="proct1 col-lg-2 col-sm-3 col-xs-3"><span class="product_name_hk">&nbsp;</span></div>
            <div class="proct2 col-lg-9 col-sm-4 col-xs-9">
                <input type="submit" id="btnSave" value="保存" class="save_continue button button-glow button-rounded button-royal" />
                <a class="save_continue button button-glow button-rounded button-royal" href="@Url.Action("List", "Method",new { Th.ProjectId})">返回</a>
                <a class="save_continue button button-glow button-rounded button-royal" href="@Url.Action("Create","MethodParameter",new { Th.ProjectId,methodId})">新增</a>
                @if (!string.IsNullOrEmpty(methodId))
                {
                    <a class="save_continue button button-glow button-rounded button-royal" href="@Url.Action("Create", "Method", new { Th.ProjectId, methodId })">修改接口及定義</a>
                }
            </div>
            <div class="proct3 col-lg-9 col-sm-5 col-xs-4"><span class="hk_cn"></span></div>
            <div class="clear"></div>
        </div>
        <!--按鈕-->
        <!--列表-->
        @Html.Action("List", "MethodParameter", new { Area = "Admin", methodId })
        <!--列表-->
    </div>
</form>
